import { getTextHeadLetter } from '@/lib/pinyin'
import { Game } from '@/type'

export const gameSorts = [
  {
    value: 'new',
    label: '最新',
    toSort: (gameList: Game[]) => {
      return [...gameList].sort((a, b) => {
        return a.createTime > b.createTime ? -1 : 1
      })
    },
  },
  {
    value: 'hot',
    label: '热门',
    toSort: (gameList: Game[]) => {
      return [...gameList]
    },
  },
  {
    value: 'default',
    label: 'A-Z',
    toSort: (gameList: Game[]) => {
      return [...gameList].sort((a, b) => {
        return getTextHeadLetter(a.name) > getTextHeadLetter(b.name) ? 1 : -1
      })
    },
  },
]
